package ${package.Service}.impl;

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.apache.http.HttpStatus;

import java.util.List;

/**
* <p>
    * ${entity}服务实现类
    * </p>
*
* @author ${author}
* @since ${date}
*/
@Service
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}>implements ${table.serviceName} {

    @Override
    public int deleteById(String id){
        if(StringUtils.isEmpty(id)){
            throw new IllegalArgumentException(String.valueOf(HttpStatus.SC_METHOD_FAILURE));
        }
        return baseMapper.deleteById(id);
    }

    @Override
    public ${entity} selectById(String id){
        if(StringUtils.isEmpty(id)){
            throw new IllegalArgumentException(String.valueOf(HttpStatus.SC_METHOD_FAILURE));
        }
        ${entity} data=baseMapper.selectById(id);
        return data;
    }

    @Override
    public List<${entity}>selectAll(${entity} record){
        QueryWrapper<${entity}>queryWrapper=new QueryWrapper<>();
        queryWrapper.setEntity(record);
        List<${entity}>list=baseMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public IPage<${entity}>selectPage(IPage<${entity}> page , ${entity} record){
        // 查询条件
        QueryWrapper<${entity}>queryWrapper=new QueryWrapper<>();
        queryWrapper.setEntity(record);
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public IPage<${entity}>getPage(IPage<${entity}>page,QueryWrapper<${entity}>queryWrapper){
        return baseMapper.selectPage(page,queryWrapper);
    }
}